<template>
  <div style="width: 50%;margin-left: 20%">
    <h1 @click="getSeller(1)">修改商家信息</h1>
    <el-form ref="seller" :model="seller" label-width="80px" >
      <el-form-item label="id" v-if="false">
        <el-input v-model="seller.id"></el-input>
      </el-form-item>
      <el-form-item label="店铺名称">
        <el-input v-model="seller.sname"></el-input>
      </el-form-item>
      <el-form-item label="店铺地址">
        <el-input v-model="seller.saddr"></el-input>
      </el-form-item>
      <el-form-item label="联系方式">
        <el-input v-model="seller.sphone"></el-input>
      </el-form-item>
      <el-form-item label="营业时间">
        <el-input v-model="seller.sworkTime"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="updateSeller">立即修改</el-button>
        <el-button>重置</el-button>
      </el-form-item>
    </el-form>

  </div>
</template>

<script>
export default {
  name: "Seller",
  data() {
    return {
      seller: {
        id: '',
        sname: '',
        saddr: '',
        sphone: '',
        sworkTime: ''
      }
    }
  },
  created() {
    this.getSeller(1)
  },
  methods: {
    updateSeller(){
      this.$axios({
        method: 'post',
        url: '/admin/updateSeller',
        data: this.seller
      }).then(res => {
        if (res.data.code == 2000){
          alert('修改成功')
        }
      })
    },
    getSeller(id){
      this.$axios({
        method: 'get',
        url: '/seller/findSeller',
        params: {
          id
        }
      }).then(res => {
        this.seller=res.data.data.data
      })
    }
  }
}
</script>

<style scoped>

</style>
